# This is a sample Python script.

# Press Shift+F10 to execute it or replace it with your code.
# Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings.
import random,os,sys,datetime
import numpy as np

def print_hi(name):
    # Use a breakpoint in the code line below to debug your script.
    print(f'Hi, {name}')  # Press Ctrl+F8 to toggle the breakpoint.

def sum(a, b):
    return a+b

def exam(score):
    if score > 100 or score < 0:
        print("错误值")
        return
    if score < 60:
        print("不及格")
    print("合格")

def getdirsize(dirpath):
    #设置一个用于累加大小的变量
    total = 0

    #获取文件夹中所有文件和文件夹
    allnames = os.listdir(dirpath)
    #遍历所有文件和文件夹，并将他们的大小累加起来
    for i in allnames:
        #遍历同时组合完整路径
        fullpath = os.path.join(dirpath,i)

        #判断是文件还是文件夹
        if os.path.isfile(fullpath):
            #print(fullpath,‘---文件‘)
            #获取文件大小
            total += os.path.getsize(fullpath)
        elif os.path.isdir(fullpath):
            #print(fullpath,‘---目录‘)
            #获取文件夹大小
            total += getdirsize(fullpath)
        else:
            #print(fullpath,‘---链接‘)
            # 获取链接大小
            total += os.path.getsize(fullpath)

    #返回总大小
    return total

# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    result = getdirsize("E:\\workspace\\NvWorks\\operation")  # 要统计的文件夹
    print(result, "B")


# See PyCharm help at https://www.jetbrains.com/help/pycharm/
